package com.bbx.taxi.client.Activity.Order;

import java.io.Serializable;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentLinkedQueue;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
import butterknife.InjectView;

import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.gclient.GMsg;
import com.bbx.api.sdk.model.official.passanger.Offciail_DevaluateBuild;
import com.bbx.api.sdk.model.official.passanger.Officail_OrderInfoBuild;
import com.bbx.api.sdk.model.official.passanger.Official_AABuild;
import com.bbx.api.sdk.model.official.passanger.Official_AABuild.OrginFos;
import com.bbx.api.sdk.model.official.passanger.Return.Offciail_DevaluateInfo.Info;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_OrderInfo;
import com.bbx.api.sdk.model.official.passanger.Return.Official_VclassInfo;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialPriceDetail;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.PayDetail;
import com.bbx.api.sdk.model.passanger.OrderDetailBuild;
import com.bbx.api.sdk.model.passanger.OrderEvaluate;
import com.bbx.api.sdk.model.passanger.Return.OrderDetails;
import com.bbx.api.sdk.model.passanger.Return.PriceDetail;
import com.bbx.api.sdk.model.passanger.Return.Jmsg.Msgs;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.official.passanger.Officail_OrderInfoNet;
import com.bbx.api.sdk.net.passeger.conn.CodeNet;
import com.bbx.api.sdk.net.passeger.conn.OrderDetailNet;
import com.bbx.api.sdk.net.passeger.conn.OrderEvaluateNet;
import com.bbx.api.util.LogUtils;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.Task.MyAATask;
import com.bbx.taxi.client.Task.MyAATask.OnAAFinishListener;
import com.bbx.taxi.client.Task.MyMonthlyTask;
import com.bbx.taxi.client.Task.MyMonthlyTask.OnMonthlyFinishListener;
import com.bbx.taxi.client.Task.MyOrderEvaluateInfoTask;
import com.bbx.taxi.client.Task.MyStarTask;
import com.bbx.taxi.client.Task.MyOrderEvaluateInfoTask.OnEvaluateInfoListener;
import com.bbx.taxi.client.Task.MyOrderEvaluateTask;
import com.bbx.taxi.client.Task.MyStarTask.OnStarListener;
import com.bbx.taxi.client.Task.MyVclassInfoTask;
import com.bbx.taxi.client.Task.MyOrderEvaluateTask.OnOrderEvaluateListener;
import com.bbx.taxi.client.Task.MyVclassInfoTask.OnVclassInfoListener;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.official.R;
import com.bbx.taxi.official.wxapi.WXPayEntryActivity;
import com.bbx.taxi.official.wxapi.WXPayEntryActivity.OnWeiXinPayFinishListener;
import com.bbx.taxi.client.Activity.MainActivity;
import com.bbx.taxi.client.Activity.Base.BaseBBXActivity;
import com.bbx.taxi.client.Activity.Menu.SetActivity;
import com.bbx.taxi.client.Activity.login.LoginActivity;
import com.bbx.taxi.client.Activity.login.LoginActivity.CodeTask;
import com.bbx.taxi.client.Adapter.OrganizationAdapter;
import com.bbx.taxi.client.Adapter.PayAdapter;
import com.bbx.taxi.client.Adapter.PayAdapter.ViewHolder;
import com.bbx.taxi.client.Adapter.PayDetailsAdapter;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.Bean.Extra.OrderMsg;
import com.bbx.taxi.client.Bean.Extra.OrganizationMsg;
import com.bbx.taxi.client.DB.AddressDB;
import com.bbx.taxi.client.DB.ContactsDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderingDB;
import com.bbx.taxi.client.Util.DataCleanManager;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.ListViewHeight;
import com.bbx.taxi.client.Util.OrderDetialToOrderList;
import com.bbx.taxi.client.Util.Tel;
import com.bbx.taxi.client.emoji.MyConvertToMsg;
import com.bbx.taxi.client.pay.alipay.PayAlipay;
import com.bbx.taxi.client.pay.alipay.PayAlipay.OnAliPayFinishListener;
import com.bbx.taxi.client.pay.weixin.PayWeixin;
import com.bbx.taxi.client.widget.MaxByteLengthEditText;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickSingleListener;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog.onClickLeftListener;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog.onClickRightListener;
import com.bbx.taxi.client.widget.Drag.AADragLayout;
import com.bbx.taxi.client.widget.Drag.AADragLayout.OnAADragViewStatusListener;
import com.bbx.taxi.client.widget.Drag.DragLayout;
import com.bbx.taxi.client.widget.Drag.DragLayout.OnDragViewStatusListener;
import com.bbx.taxi.client.widget.SlidingCard2.DiscoverContainerView;
import com.bbx.taxi.client.widget.SlidingCard2.SlidingCard;
import com.bbx.taxi.client.widget.SlidingCard2.DiscoverContainerView.OnFinish;
import com.bbx.taxi.client.widget.SlidingCard2.OrderVo;
import com.bbx.taxi.client.widget.pop.SharePopView;
import com.bbx.taxi.client.widget.pop.SharePopView.OnShareDetaiFinish;
import com.umeng.socialize.sso.UMSsoHandler;

/**
 * 订单评价
 * 
 */
public class OrderEvaluationActivity2 extends BaseBBXActivity implements
		OnDragViewStatusListener,OnAADragViewStatusListener, OnShareDetaiFinish,
		OnWeiXinPayFinishListener, OnAliPayFinishListener 
		,OnOrderEvaluateListener,OnVclassInfoListener
		,OnEvaluateInfoListener,OnStarListener,OnAAFinishListener,OnMonthlyFinishListener{
	/**评价等级内容*/
	public static final String EVALUATE_LEVEL_1="非常不满意，各方面都很差";
	public static final String EVALUATE_LEVEL_2="不满意，比较差";
	public static final String EVALUATE_LEVEL_3="一般，需要改善";
	public static final String EVALUATE_LEVEL_4="比较满意";
	public static final String EVALUATE_LEVEL_5="非常满意";
	
	/** 待评价状态 */
	public static final int STATUS_EVA = 0;
	/** 正在评价状态 */
	public static final int STATUS_EVAING = 1;
	/** 完成状态 */
	public static final int STATUS_FINISH = 2;
	/** 支付状态 */
	public static final int STATUS_PAY = 3;
	/** 分摊费用 */
	public static final int STATUS_APPORTION = 4;
	// 第三方支付平台的优惠
	public String DISCOUNT_GONGWU = "0";
	public String DISCOUNT_ALIPAY = "0";
	public String DISCOUNT_WEIXIN = "0";
	public String DISCOUNT_LINE = "0";
	@InjectView(R.id.layout_main)
	RelativeLayout layout_main;
	@InjectView(R.id.dragLayout)
	public DragLayout dragLayout;
	@InjectView(R.id.AAdragLayout)
	public AADragLayout AAdragLayout;
	@InjectView(R.id.test)
	View test;
	@InjectView(R.id.listview_pay)
	ListView listview_pay;
	/** 费用明细列表视图 */
	@InjectView(R.id.lv_paydetail)
	ListView listview_paydetail;
	@InjectView(R.id.tv_cost_detail)
	TextView tv_cost_detail;
	@InjectView(R.id.contentview)
	DiscoverContainerView contentView;
	/** 司机名称 */
	@InjectView(R.id.tv_driver_name)
	TextView tv_driver_name;
	/** 车牌号 */
	@InjectView(R.id.tv_car_No)
	TextView tv_car_No;
	/** 需支付金额 */
	@InjectView(R.id.tv_pay)
	TextView tv_pay;
	/** 内容 */
	@InjectView(R.id.include_cost)
	LinearLayout layout_cost;
	/** 费用明细的具体内容，该布局替换成另外一个视图出行，暂不可用 */
	@InjectView(R.id.layout_cost_detail)
	RelativeLayout layout_cost_detail;
	/** 提示语 */
	@InjectView(R.id.layout_anonymous)
	RelativeLayout layout_anonymous;
	@InjectView(R.id.et_message)
	MaxByteLengthEditText et_message;
	@InjectView(R.id.et_message2)
	TextView et_message2;
	@InjectView(R.id.layout_message2)
	LinearLayout layout_message2;
	/** 待评价布局 */
	@InjectView(R.id.layout_evaluate)
	LinearLayout layout_evaluate;
	/** 再次下单 */
	@InjectView(R.id.btn_confirm)
	Button btn_confirm;
	/** 再次下单 TextViewq */
//	@InjectView(R.id.tv_confirm)
//	TextView tv_confirm;
	/** 评价 */
	@InjectView(R.id.rb_rating)
	RatingBar rb_rating;
	@InjectView(R.id.tv_rating)
	TextView tv_rating;
	@InjectView(R.id.rb_rating_b)
	RatingBar rb_rating_b;
	/** 显示需支付和已支付 */
	@InjectView(R.id.tv_need_pay)
	TextView tv_need_pay;
	@InjectView(R.id.layout_payway)
	RelativeLayout layout_payway;
	/** hint支付类型 */
	@InjectView(R.id.layout_hint_paytype)
	RelativeLayout layout_hint_paytype;
	@InjectView(R.id.tv_hint_paytype)
	TextView tv_hint_paytype;
	/** 我要优惠劵 */
	@InjectView(R.id.btn_coupon)
	Button btn_coupon;
	/** 阴影 */
	@InjectView(R.id.pop_background)
	public View pop_background;
	@InjectView(R.id.ib_sjtel)
	ImageButton ib_sj;
	@InjectView(R.id.tv_wf)
	TextView tv_wf;
	@InjectView(R.id.tv_apportion_detail)
	TextView tv_apportion_detail;//分摊明细
	@InjectView(R.id.layout_apportion)
	LinearLayout layout_apportion;
	@InjectView(R.id.layout_detail)
	LinearLayout layout_detail;
	@InjectView(R.id.btn_addOrganization)
	Button btn_addOrganization;
	@InjectView(R.id.tv_cost_apportion_content)
	TextView tv_cost_apportion_content;
	@InjectView(R.id.tv_levelcontent)
	TextView tv_levelcontent;
	/** 订单Id列表 */
	ConcurrentLinkedQueue<String> dataList = new ConcurrentLinkedQueue<String>();
	/** 选择支付类型列表 */
	ConcurrentLinkedQueue<Integer> payList = new ConcurrentLinkedQueue<Integer>();
	/** 界面状态 */
	ConcurrentLinkedQueue<Integer> statusList = new ConcurrentLinkedQueue<Integer>();
	/** 是否刷新成功 */
	ConcurrentLinkedQueue<Boolean> successList = new ConcurrentLinkedQueue<Boolean>();
	/** 是否刷新成功 */
	ConcurrentLinkedQueue<OfficialOrderList> myOrderListList = new ConcurrentLinkedQueue<OfficialOrderList>();
	private int order_type;
	private int viewId;
	/** 订单Id集合 */
	private List<String> lits_order_id = new ArrayList<String>();
	/** 界面状态，最下面的那个页面的，主要用于传递到卡片上去。卡片根据状态显示样本。评价状态，0待评价，1正在评价，2已评价 ,3待支付 */
	public int status = STATUS_PAY;
	/** 评价状态，1待评价，2已评价 */
	public int eva_status = Value.VALUATE_STATUS_NO;
	private OfficialOrderList mOfficialOrderList;
	private MyOrderDB db_myorder;// 我的订单数据库
	private MyOrderingDB db_myordering;// 我的订单数据库
	private OrderDetailTask mOrderDetailTask;
	private List<OrginFos> list_orginfos=new ArrayList<OrginFos>();
	private boolean isonNotify = false;
	private boolean isTouch = true;
	private String order_id;
	private MainAttribute main;
	/** 支付列表 */
	private List<Map<String, String>> list;
	/** 支付费用明细列表 */
	private List<Map<String, String>> list_paydetail = new ArrayList<Map<String, String>>();
	/** 支付费用明细列表【更加详细，及另外一个界面】 */
	private List<Map<String, String>> list_paydetail_more = new ArrayList<Map<String, String>>();
	private PayAdapter mPayAdapter;
	private PayDetailsAdapter mPayDetailsAdapter;
	// 支付id,则为类型，0为银联
	private int pay_id = 0;
	/** 需要支付的金额，不包括第三方支付的优惠 */
	private boolean isSuccess = false;
	/** 费用详情的popview */
	private PopupWindow popview;
	/** 车费总计 */
	private double total_fare;
	/** 车费 */
	private double fare;
	/** 过路费 */
	private double highwey_fee = 0;
	/** 优惠劵 */
	private double coupon;
	/** 需要支付 */
	private double pay;
	/** 第三方支付优惠 */
	private double discount;
	/** 分享POP */
	public SharePopView mSharePopView;
	/** 用于判断是否执过，setView里的setStatus，执行过了，则不在调用 */
	public boolean isViewAndStatus = false;
	/** 第一次出现加载框的订单详情， */
	public boolean FirstLoad = true;
	private Intent intent;
	/** 支付方式 */
	private String pay_gate;
	/**	优惠大礼包*/
	private MyCouponDailog coupondialog;
	/**判断是否是月结*/
	private boolean isAA=false;
	int down_y = 0;
	private List<Map<String, String>> list_organization;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		jmsg_data = "";
		setContentView(R.layout.activity_orderevaluation2);
		super.onCreate(savedInstanceState);
		
	}

	public void onSetTitle(int status) {
		this.status = status;
		switch (status) {
		// 支付状态
		case STATUS_PAY:
			setTitle(true, getString(R.string.title_pay), -1,
					getString(R.string.complaint));
			setTitle(R.string.title_pay);
			break;
		// 待评价状态
		case STATUS_EVA:
			setTitle(true, getString(R.string.title_pay_finish), -1,
					getString(R.string.complaint));
			break;
		// 正在评价状态
		case STATUS_EVAING:
			setTitle(true, getString(R.string.title_pay_finish), -1,
					getString(R.string.complaint));
			break;
		// 完成状态
		case STATUS_FINISH:
			setTitle(true, getString(R.string.title_pay_finish), -1,
					getString(R.string.complaint));
			break;
	     // 费用分摊
		case STATUS_APPORTION:
			setTitle(true, getString(R.string.title_cost_confirm), -1,
					getString(R.string.complaint));
			break;
		}
	}

	/**
	 * 注意事项，如果在这边分享了优惠大礼包，然后返回界面，则会刷新父类的订单列表，，这时候后台一定要有【过路费】这些信息
	 * 人，然后还要刷新下订单详情，，如果没有
	 * ，则去掉super.onResume();不刷新列表，，不然，，下个订单过来的时候，，由于没有【过路费】，则会报错
	 */
	@Override
	protected void onResume() {
		super.onResume();
		hideInput();
//		getOrderDetail(order_id, false);
	}

	@Override
	protected void initView() {
		super.initView();
		tv_pay.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/num.ttf"));
		coupondialog = new MyCouponDailog(context);
		layout_main.setVisibility(View.GONE);
		mSharePopView = new SharePopView(context, pop_background);
		mPayDetailsAdapter = new PayDetailsAdapter(context, list_paydetail);
		listview_paydetail.setAdapter(mPayDetailsAdapter);
		tv_cost_detail.setOnClickListener(this);
		tv_apportion_detail.setOnClickListener(this);
		dragLayout.setOnDragViewStatusListener(this);
		AAdragLayout.setOnAADragViewStatusListener(this);
		ib_sj.setOnClickListener(this);
		btn_addOrganization.setOnClickListener(this);
		et_message.setOnEditorActionListener(new OnEditorActionListener() {
			@Override
			public boolean onEditorAction(TextView arg0, int arg1,
					KeyEvent event) {
				return (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
			}
		});
		et_message.setMaxByteLength(60);
		et_message.setOnClickListener(this);
		btn_coupon.setOnClickListener(this);
		isonNotify = true;
		db_myorder = new MyOrderDB(this);
		db_myordering = new MyOrderingDB(this);
		layout_evaluate.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				int move_y = 0;
				if(event.getAction() == MotionEvent.ACTION_DOWN) {
					down_y=(int) event.getY();
				}
                if(event.getAction() == MotionEvent.ACTION_UP) {
                	move_y=(int) event.getY();
					if((move_y-down_y)>50){
						if(getStatus()==STATUS_EVAING){
							setStatus(STATUS_EVA);
						}
					}
				}
				return false;
			}
		});
		intent = getIntent();
		final String order_id = intent.getExtras().getString(
				OrderMsg.order_id_finish);
		this.order_id = order_id;

		if (order_id == null || order_id.equals(""))
			finish();
		try {
			initView2();
		} catch (Exception e) {
		}
		getOrderDetail(order_id, true);
	}

	@Override
	protected void initData() {
		main=MainAttribute.getInstance();
	}

	private void initView2() {
		// 默认支付0元
		tv_pay.setText(FormatUtil.onFormatDecimal(0));
		btn_confirm.setText(getString(R.string.confirm_pay2));
		new AsyncTask<Void, Void, Void>() {
			@Override
			protected Void doInBackground(Void... params) {
				final String finish_type = intent.getExtras().getString(
						OrderMsg.finish_type);
				if (finish_type.equals(OrderMsg.finish_ing)) {
					mOfficialOrderList = db_myordering
							.onReadDB_ing(context, order_id);
				} else {
					mOfficialOrderList = db_myorder.onReadDB(context, order_id);
				}

				return null;
			}

			@Override
			protected void onPostExecute(Void result) {
				if (mOfficialOrderList!=null&&mOfficialOrderList.getOrder_id() != null) {
					setView();
				}
				super.onPostExecute(result);
			}

		}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}

	private void setView() {
		try{
		if(mOfficialOrderList.getOrder_id()!=null){
		onSetPayList(Integer.parseInt(mOfficialOrderList.getOwn_expense()));
		// 初始化评价状态
		if (mOfficialOrderList.getValuate_status() != null) {
			eva_status = Integer.parseInt(mOfficialOrderList.getValuate_status());
		}
		try{
			//判断是否是AA
			PayDetail mPayDetail=mOfficialOrderList.getPayDetail();
			if(mPayDetail!=null&&mPayDetail.getGateway()!=null){
				if(mPayDetail.getGateway().equals(Value.PAYWAY_AA)){
					isAA=true;
					pay_gate=getString(R.string.pay_way_gongwu);
				}else if(mPayDetail.getGateway().equals(Value.PAYWAY_WEIXIN)){
					isAA=false;
					pay_gate=getString(R.string.pay_way_weixin);
				}else if(mPayDetail.getGateway().equals(Value.PAYWAY_LINE)){
					isAA=false;
					pay_gate=getString(R.string.pay_way_line);
				}else if(mPayDetail.getGateway().equals(Value.PAYWAY_ALIPAY)){
					isAA=false;
					pay_gate=getString(R.string.pay_way_alipay);
				}else if(mPayDetail.getGateway().equals(Value.PAYWAY_WEIXIN_JSAPI)){
					isAA=false;
					pay_gate=getString(R.string.pay_way_weixin);
				}else if(mPayDetail.getGateway().equals(Value.PAYWAY_MONTHLY)){
					isAA=false;
					pay_gate=getString(R.string.pay_way_gongwu);
				}
			}
		}catch(Exception e){
			LogUtils.e("就版本不能用");
		}
		
		int order_status = Integer.parseInt(mOfficialOrderList.getOrder_status());
		if (order_status == Value.ORDER_STATUS_OFFCAR) {
			status = STATUS_PAY;
		} else {
			switch (eva_status) {
			case Value.VALUATE_STATUS_NO:
				status = STATUS_EVA;
				break;
			case Value.VALUATE_STATUS:
				status = STATUS_FINISH;
				break;
			}
		}
		setStatus(status);
		isViewAndStatus = true;
//		if (!isViewAndStatus) {
//			setStatus(status);
//			isViewAndStatus = true;
//		}
		lits_order_id.add(order_id);
		tv_wf.setText(mOfficialOrderList.getRound_trip().equals("1")?R.string.round_trip:R.string.round_trip_no);
		tv_driver_name.setText(mOfficialOrderList.getDriver_name());
		tv_car_No.setText(mOfficialOrderList.getCar_NO());
		// tv_time.setText(DateFormat.onDateRemove_ss(mOfficialOrderList
		// .getAppoint_time()));
		order_type = Integer.parseInt(mOfficialOrderList.getOrder_type());
		switch (order_type) {
		case Value.ORDER_TYPE_SN:
			// tv_order_type.setText(R.string.sn);
			viewId = Value.VIEWID_SN;
			// tv_count.setVisibility(View.GONE);
			break;
		case Value.ORDER_TYPE_KJ:
			// tv_order_type.setText(R.string.kj);
			viewId = Value.VIEWID_KJ;
			// tv_count.setText(String.format(getString(R.string.num_jian),
			// mOfficialOrderList.getOrderDetail().getCount()));
			break;
		case Value.ORDER_TYPE_PC:
			// tv_order_type.setText(R.string.pc);
			// tv_count.setText(String.format(getString(R.string.num),
			// mOfficialOrderList.getOrderDetail().getCount()));
			viewId = Value.VIEWID_PC;
			break;
		case Value.ORDER_TYPE_BC:
			// tv_order_type.setText(R.string.bc);
			// tv_count.setText(String.format(getString(R.string.num_car),
			// mOfficialOrderList.getOrderDetail().getCount()));
			viewId = Value.VIEWID_BC;
			break;
		}

		// tv_start.setText(mOfficialOrderList.getOrderDetail().getStart().getAddress());
		// tv_end.setText(mOfficialOrderList.getOrderDetail().getEnd().getAddress());
//		rb_rating.setRating(FormatUtil.onFormatStar((float) mOfficialOrderList
//				.getDriver_star()));
//		tv_rating.setText(FormatUtil.onFormatStar((float) mOfficialOrderList
//				.getDriver_star()) + "");
		MyStarTask.getInstance(context,mOfficialOrderList.getOrder_id(),mOfficialOrderList.getDriver_id()).setOnStarListener(this);
		if (dataList.size() > 0) {
			contentView.setVisibility(View.VISIBLE);
			setOnCloseSwipeLayout(true);
		} else {
			setOnCloseSwipeLayout(false);
		}
		contentView.initCardView(OrderEvaluationActivity2.this, dataList,
				payList, statusList, successList, myOrderListList);
		contentView.setOnFinish(new OnFinish() {

			@Override
			public void onFinish() {
				setOnCloseSwipeLayout(false);
				onSetTitle(status);

			}
		});
		btn_confirm.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (btn_confirm.getText().toString()
						.equals(getString(R.string.btn_confirmation))) {
					getOrderDetail(order_id, true);
				} else {
					// 提交评价
					if (getStatus() == STATUS_EVAING) {
						// 提交评价
						Offciail_DevaluateBuild mOffciail_DevaluateBuild = new Offciail_DevaluateBuild(
								context);
						mOffciail_DevaluateBuild.tc_id = main.getTc_id();
						mOffciail_DevaluateBuild.driver_id = mOfficialOrderList.driver_id;
						mOffciail_DevaluateBuild.driver_name = mOfficialOrderList.driver_name;
						mOffciail_DevaluateBuild.driver_phone=mOfficialOrderList.driver_phone;
						mOffciail_DevaluateBuild.passenger_id=mApplication.getUid();
						mOffciail_DevaluateBuild.passenger_name=mApplication.getRealName();
						mOffciail_DevaluateBuild.passenger_phone=mApplication.getRealPhone();
						mOffciail_DevaluateBuild.order_id = order_id;
		
						mOffciail_DevaluateBuild.star = ((int) rb_rating_b.getRating()) * 20;
						mOffciail_DevaluateBuild.content = new MyConvertToMsg()
								.parseEmoji(context, et_message.getText()
										.toString());
						MyOrderEvaluateTask.getInstance(context, mOffciail_DevaluateBuild).setOnOrderEvaluateListener(OrderEvaluationActivity2.this);
					}
					// 再次下单
					else if (getStatus() == STATUS_EVA
							|| getStatus() == STATUS_FINISH) {
						if(mOfficialOrderList.mOfficial_VclassInfo!=null){
						MainAttribute main = MainAttribute.getInstance();
						main.setAttribute(context,mOfficialOrderList);

						Intent intent = new Intent();
						intent.setClass(OrderEvaluationActivity2.this,
								MainActivity.class);
						intent.putExtra(MainMsg.extra_viewpageId, viewId);
						intent.putExtra(MainMsg.extra_agin_xiadan, MainMsg.AGAIB_XIADAN);
						intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // 注意本行的FLAG设置
						startActivity(intent);}else{	
							ToastUtil.showToast(context, R.string.try_again_later);
						}
					}
					// 支付
					else if (getStatus() == STATUS_PAY) {
						if (!isSuccess) {
							ToastUtil.showToast(context, R.string.no_network);
						} else {
							if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_GWYJ)) {
							  setStatus(STATUS_APPORTION);

							} else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_ALIPAY)) {
								PayAlipay payalipay = new PayAlipay(context,
										order_id);
								payalipay
										.setOnAliPayFinishListener(OrderEvaluationActivity2.this);
								payalipay.pay();

							} else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_WEIXIN)) {
								WXPayEntryActivity
										.setOnWeiXinPayFinishListener(OrderEvaluationActivity2.this);
								PayWeixin payweixin = new PayWeixin(context,
										order_id);
								payweixin.pay();
							}
							else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_LINE)) {
								final MyAlertDailog dialog=new MyAlertDailog(context);
								dialog.setTitle(getString(R.string.mydailog_title));
								dialog.setContent2(Html.fromHtml("请等待司机按下“<font color=\"#fe5000\">线下收款</font>”\n按钮 ，该订单即可完成"));
								dialog.setSingle(getString(R.string.mydailog_confirm_cancel));
								if (dialog != null && !dialog.isShowing()) {
									dialog.show();
								}
								dialog.setOnClickSingleListener(new onClickSingleListener() {
									
									@Override
									public void onClickSingle() {
										dialog.dismiss();
									}
								});

							}

						}
					}else if(getStatus() == STATUS_APPORTION){
						//月结支付
						if(list_orginfos==null||list_orginfos.isEmpty()){
							MyMonthlyTask.getInstance(context, order_id).setOnMonthlyFinishListener(OrderEvaluationActivity2.this);

						}else{
						//AA支付
							final MyAlertDailog dialog=new MyAlertDailog(context);
							dialog.setContent(tv_cost_apportion_content.getText().toString());
							dialog.setLeftButtonText(getString(R.string.mydailog_cancel));
							dialog.setRightButtonText(getString(R.string.mydailog_confirm_cancel));
							if (dialog != null && !dialog.isShowing()) {
								dialog.show();
							}
							dialog.setOnClickRightListener(new MyAlertDailog.onClickRightListener() {
								
								@Override
								public void onClickRight() {
									MyAATask.getInstance(context, order_id, list_orginfos).setOnAAFinishListener(OrderEvaluationActivity2.this);
								}
							});
							
							

						}
					}
				}
			}
		});
		rb_rating_b.setIsIndicator(true);
		rb_rating_b.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
			
			@Override
			public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
				switch((int)arg1){
				case 0:
					tv_levelcontent.setVisibility(View.INVISIBLE);
					break;
				case 1:
					tv_levelcontent.setText(EVALUATE_LEVEL_1);
					tv_levelcontent.setVisibility(View.VISIBLE);
					break;
				case 2:
					tv_levelcontent.setText(EVALUATE_LEVEL_2);
					tv_levelcontent.setVisibility(View.VISIBLE);
					break;
				case 3:
					tv_levelcontent.setText(EVALUATE_LEVEL_3);
					tv_levelcontent.setVisibility(View.VISIBLE);
					break;
				case 4:
					tv_levelcontent.setText(EVALUATE_LEVEL_4);
					tv_levelcontent.setVisibility(View.VISIBLE);
					break;
				case 5:
					tv_levelcontent.setText(EVALUATE_LEVEL_5);
					tv_levelcontent.setVisibility(View.VISIBLE);
					break;
				}
				
			}
		});
		rb_rating_b.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (!isTouch)
					return true;
				switch (event.getAction()) {
				case MotionEvent.ACTION_DOWN:
					setStatus(STATUS_EVAING);
					break;
				}
				return false;
			}
		});
		layout_main.setVisibility(View.VISIBLE);
		}else{
			startActivity(new Intent(this,OrderDelete.class));
			finish();
		}	
	}catch(Exception e){
		getOrderDetail(order_id, false);
	}
	}

	/**
	 * 设置支付列表
	 */
	private void onSetPayList(int own_expense) {
		list = new ArrayList<Map<String, String>>();
		Map<String, String> map = new HashMap<String, String>();
		 // 公务
		if(own_expense==Value.NOOWN){
		 map.put(PayAdapter.TYPE, PayAdapter.TYPE_GWYJ);
		 map.put(PayAdapter.TEXT, getString(R.string.pay_way_gongwu));
		 map.put(PayAdapter.DISCOUNT, DISCOUNT_GONGWU);
		 list.add(map);
		}else{
			// 支付宝
			map = new HashMap<String, String>();
			map.put(PayAdapter.TYPE, PayAdapter.TYPE_ALIPAY);
			map.put(PayAdapter.TEXT, getString(R.string.pay_way_alipay));
			map.put(PayAdapter.DISCOUNT, DISCOUNT_ALIPAY);
			list.add(map);
			if( WXPayEntryActivity.isWXAppInstalledAndSupported(context)){
				// 微信
				map = new HashMap<String, String>();
				map.put(PayAdapter.TYPE, PayAdapter.TYPE_WEIXIN);
				map.put(PayAdapter.TEXT, getString(R.string.pay_way_weixin));
				map.put(PayAdapter.DISCOUNT, DISCOUNT_WEIXIN);
				map.put(PayAdapter.AVAILABLE, WXPayEntryActivity
						.isWXAppInstalledAndSupported(context) ? "true" : "false");
				list.add(map);
			}	
			//现金支付
			if(own_expense==Value.OWN){
			map = new HashMap<String, String>();
			map.put(PayAdapter.TYPE, PayAdapter.TYPE_LINE);
			map.put(PayAdapter.TEXT, getString(R.string.pay_way_line));
			map.put(PayAdapter.DISCOUNT, DISCOUNT_LINE);
			list.add(map);
			}
		}

		discount = Double
				.parseDouble(list.get(pay_id).get(PayAdapter.DISCOUNT));
		mPayAdapter = new PayAdapter(context, list);
		listview_pay.setAdapter(mPayAdapter);
		ListViewHeight.setListViewHeightBasedOnChildren(listview_pay);
		listview_pay.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View v, int position,
					long arg3) {
				try {
					discount = Double.parseDouble(list.get(position).get(
							PayAdapter.DISCOUNT));
					pay = total_fare - coupon - discount;
					if (pay < 0)
						pay = 0;
				} catch (Exception e) {
				}
				tv_pay.setText(FormatUtil.onFormatDecimal(pay));
				if (status == STATUS_PAY) {
					btn_confirm.setText(getString(R.string.confirm_pay2));
				}

				pay_id = position;
				ViewHolder vHollder = (ViewHolder) v.getTag();
				if (!vHollder.cb_pay.isChecked()) {
					vHollder.cb_pay.toggle();
				}
				for (int i = 0; i < list.size(); i++) {
					if (i == position) {
						mPayAdapter.isSelected.put(i, true);
					} else {
						mPayAdapter.isSelected.put(i, false);
					}
				}
				mPayAdapter.notifyDataSetInvalidated();
			}
		});
	}

	private void addCardView(String order_id) {
		if((payList!=null&&payList.contains(order_id))||this.order_id.equals(order_id)){
			return;
		}
		myOrderListList.add(mOfficialOrderList);
		dataList.add(this.order_id);
		payList.add(pay_id);
		statusList.add(getStatus());
		successList.add(isSuccess);
		contentView.initCardView(OrderEvaluationActivity2.this, dataList,
				payList, statusList, successList, myOrderListList);
		isSuccess = false;
		this.order_id = order_id;
		// 重置支付选项
		pay_id = 0;
		for (int i = 0; i < list.size(); i++) {
			if (i == pay_id) {
				mPayAdapter.isSelected.put(i, true);
			} else {
				mPayAdapter.isSelected.put(i, false);
			}
		}
		mPayAdapter.notifyDataSetInvalidated();

		// 如果contentView数据为空，则add为加旧的，另外一个布局加新的，
		if (contentView.getVisibility() == View.GONE) {
			contentView.setVisibility(View.VISIBLE);
		}
		setOnCloseSwipeLayout(true);
		onScrollOrigin();

		// mMyOrderList赋值要在添加卡片后面
		mOfficialOrderList = db_myorder.onReadDB(context, order_id);
		lits_order_id.add(order_id);
		tv_driver_name.setText(mOfficialOrderList.getDriver_name());
		// tv_time.setText(DateFormat.onDateRemove_ss(mOfficialOrderList
		// .getAppoint_time()));
		order_type = Integer.parseInt(mOfficialOrderList.getOrder_type());
		switch (order_type) {
		case Value.ORDER_TYPE_SN:
			// tv_order_type.setText(R.string.sn);
			// tv_count.setVisibility(View.GONE);
			break;
		case Value.ORDER_TYPE_PC:
			// tv_order_type.setText(R.string.pc);
			// tv_count.setText(String.format(getString(R.string.num),
			// mOfficialOrderList.getOrderDetail().getCount()));
			break;
		case Value.ORDER_TYPE_BC:
			// tv_order_type.setText(R.string.bc);
			// tv_count.setText(String.format(getString(R.string.num_car),
			// mOfficialOrderList.getOrderDetail().getCount()));
			break;
		case Value.ORDER_TYPE_KJ:
			// tv_order_type.setText(R.string.kj);
			// tv_count.setText(String.format(getString(R.string.num_jian),
			// mOfficialOrderList.getOrderDetail().getCount()));
			break;
		}
		// tv_start.setText(mOfficialOrderList.getOrderDetail().getStart().getAddress());
		// tv_end.setText(mOfficialOrderList.getOrderDetail().getEnd().getAddress());
		//获取新的订单的司机星星
		MyStarTask.getInstance(context,mOfficialOrderList.getOrder_id(),mOfficialOrderList.getDriver_id()).setOnStarListener(this);
//		rb_rating.setRating(FormatUtil.onFormatStar((float) mOfficialOrderList
//				.getDriver_star()));
//		tv_rating.setText(FormatUtil.onFormatStar((float) mOfficialOrderList
//				.getDriver_star()) + "");
		getOrderDetail(order_id, false);
		onRecovery();
	}

	/**
	 * 恢复界面原来的样子
	 */
	public void onRecovery() {
		isAA=false;
		setStatus(STATUS_EVA);
	}

	/**
	 * 获取订单详情
	 */
	public void getOrderDetail(String order_id, boolean isLoading) {
		if(order_id!=null){
			Officail_OrderInfoBuild mOrderDetail = new Officail_OrderInfoBuild(context);
		mOrderDetail.passenger_id = mApplication.getUid();
		mOrderDetail.order_id = order_id;
		mOrderDetailTask = new OrderDetailTask(context, mOrderDetail, isLoading);
		mOrderDetailTask.execute();
		}
	}

	/**
	 * 订单详情
	 */
	private class OrderDetailTask extends BaseAsyncTask {

		private Officail_OrderInfoBuild mOrderDetail;
		private boolean isLoading;

		public OrderDetailTask(Activity context, Officail_OrderInfoBuild mOrderDetail,
				boolean isLoading) {
			super(context, isLoading);
			this.isLoading = isLoading;
			this.mOrderDetail = mOrderDetail;
		}

		@Override
		public void onSuccess(Object object) {
			isSuccess = true;
			if (object != null) {
				Officail_OrderInfo mOfficail_OrderInfo = (Officail_OrderInfo) object;
				if (mOfficail_OrderInfo != null&&mOfficail_OrderInfo.getInfo()!=null&&mOfficail_OrderInfo.getInfo().getOrder_id()!=null) {
					mOfficialOrderList=mOfficail_OrderInfo.getInfo();
					MyVclassInfoTask.getInstance(OrderEvaluationActivity2.this, mOfficialOrderList.getTcId(), mOfficialOrderList.getVehicle_id()).setOnVclassInfoListener(OrderEvaluationActivity2.this);
					main.setTc_id(mOfficialOrderList.getTcId());					
					
					
					// //////////////////////////////////////////
					// 设置试图,只有isLoading=true的时候，才重新设置试图，，isLoading=true则是第一次启动和评价才有，FirstLoad为第一次启动加载框才有，，其他一概不重新设置试图
					if (isLoading && FirstLoad) {
						FirstLoad = false;
						setView();

					}

					// 如果是确认中...却订单已经完成了，则跳转到待评价
					if (btn_confirm.getText().toString()
							.equals(getString(R.string.btn_confirmation))
							&& Integer.parseInt(mOfficialOrderList.getOrder_status()) == Value.ORDER_STATUS_FINISH) {
						onPaySuccuss();
					} else {
						// ////////////////////////
						// 支付车费
						String str_fare = FormatUtil
								.onFormatPrice(mOfficialOrderList
										.getActual_price());
						if(str_fare==null||str_fare.equals(""))str_fare="0";
						fare = Double.parseDouble(str_fare);
						// ///////////////////////////过路费已经其他费用////////////////////
						//
						JSONObject json_price_detail = null;
						try {
							json_price_detail = new JSONObject(mOfficialOrderList.getPrice_Detail());
						} catch (JSONException e) {
							e.printStackTrace();
						}
						OfficialPriceDetail price_detail=null;
						if(json_price_detail!=null){
						 price_detail = (OfficialPriceDetail) new JsonBuild().getData(OfficialPriceDetail.class,
								 json_price_detail.toString());
						}
						//如果是市内单，则车费另外获取，在PriceDetail里面
						if (price_detail != null&&Integer.parseInt(mOfficialOrderList.getOrder_type()) == Value.ORDER_TYPE_SN) {
							fare=Double.parseDouble(FormatUtil.onFormatPrice(price_detail.getMetered_fee()));
						}
						if (price_detail != null
								&& price_detail.getActual_price() != -1) {
							coupon = price_detail.getDiscountAmt();
							
							String price_detail_string = new JsonBuild().setModel(price_detail).getJsonString();
							mOfficialOrderList.setPrice_Detail(price_detail_string);
							// 需支付
							pay = Double.parseDouble(FormatUtil
									.onFormatPrice(price_detail
											.getActual_price()))
									- discount;
							// 车费总计
							total_fare = Double.parseDouble(FormatUtil
									.onFormatPrice(price_detail.getTotal()));
							// 支付方式【获取位置暂时替换】
//							if (price_detail.getPay_gate() != null) {
//								if (price_detail.getPay_gate().equals(
//										PriceDetail.ALIPAY)) {
//									pay_gate = getString(R.string.pay_way_alipay);
//								} else if (price_detail.getPay_gate().equals(
//										PriceDetail.WEIXIN)||price_detail.getPay_gate().equals(
//												PriceDetail.WEIXIN_JSAPI)) {
//									pay_gate = getString(R.string.pay_way_weixin);
//								} else if (price_detail.getPay_gate().equals(
//										PriceDetail.LINE)) {
//									pay_gate = getString(R.string.pay_way_line);
//								}
//								tv_hint_paytype.setText(pay_gate);
//							}
						} else {
							if (mOfficialOrderList.getDiscount() != null) {
								coupon = mOfficialOrderList
										.getDiscount().getSum();
							}
							// 车费总计=车费
							total_fare = fare;
							pay = total_fare - discount - coupon;
						}
						if (pay < 0)
							pay = 0;
						tv_pay.setText(FormatUtil.onFormatDecimal(pay));
						if (status == STATUS_PAY) {
							btn_confirm.setText(getString(R.string.confirm_pay2));
						}
						// ////////////////////////
//							rb_rating.setRating(FormatUtil
//									.onFormatStar((float) mOfficialOrderList.getDriver_star()));
//							tv_rating.setText(FormatUtil
//									.onFormatStar((float) mOfficialOrderList.getDriver_star())
//									+ "");
						if (mOfficialOrderList.getCar_NO() != null)
							tv_car_No.setText(mOfficialOrderList
									.getCar_NO());
						if (et_message2.getText().toString().equals("")
								&& mOfficialOrderList.getSuggest() != null)
							et_message2.setText(mOfficialOrderList
									.getSuggest());

//						if (mOfficialOrderList.getValuate_status() != null
//								&& Integer.parseInt(mOfficialOrderList
//										.getValuate_status()) == (Value.VALUATE_STATUS)) {// 如果该订单已完成，则显示完成界面
//							rb_rating_b.setRating(FormatUtil.onFormatStar((mOfficialOrderList.getStar())));
//						}
						// 设置值
						mOfficialOrderList.setPrice(mOfficialOrderList
								.getPrice()+"");
						mOfficialOrderList.setDriver_star((float) mOfficialOrderList.getDriver_star());
						mOfficialOrderList.setSuggest(mOfficialOrderList
								.getSuggest());
						mOfficialOrderList.setStar(mOfficialOrderList.getStar());
						if (mOfficialOrderList.getDiscount() != null) {
							mOfficialOrderList.setCoupon_sum(mOfficialOrderList.getDiscount().getSum()+"");
							list_paydetail.clear();
							// 添加车费总计
							addPayDetail(getString(R.string.total_fare),
									total_fare + "",
									PayDetailsAdapter.TYPE_PRICE);
							// 添加优惠劵
							addPayDetail(getString(R.string.end_coupon), coupon
									+ "", PayDetailsAdapter.TYPE_REDUCE);
							mPayDetailsAdapter.notifyDataSetChanged();
							ListViewHeight
									.setListViewHeightBasedOnChildren(listview_paydetail);
						} else {

						}
						mOfficialOrderList.setValuate_status(mOfficialOrderList.getValuate_status());
						db_myorder.onUpdate(mOfficialOrderList);
					}
				}else{
					startActivity(new Intent(context,OrderDelete.class));
				}

			} else {
				// 设置试图,只有isLoading=true的时候，才关闭程序，，isLoading=true则是第一次启动和评价才有，FirstLoad为第一次启动加载框才有，，其他一概不关闭
				if (isLoading && FirstLoad) {
					finish();
				}
				ToastUtil.showToast(context, R.string.no_network);
			}
		}

		@Override
		public void onFailed(int status, String msg) {
			// 设置试图,只有isLoading=true的时候，才关闭程序，，isLoading=true则是第一次启动和评价才有，FirstLoad为第一次启动加载框才有，，其他一概不关闭
			if (isLoading && FirstLoad) {
				finish();
			}
			ToastUtil.showToast(context, R.string.no_network);
		}

		@Override
		protected Object doInBackground(Object... params) {
			// TODO Auto-generated method stub
			String json = new JsonBuild().setModel(mOrderDetail).getJson();
			return new Officail_OrderInfoNet(context, json);
		}
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK) {	
			onBack();
			return true;

		}
		return false;
	}
    public void onBack(){
    	if(getStatus()==STATUS_APPORTION){
			setStatus(STATUS_PAY);
			return ;
		}
		// 费用明细
		if (tv_title.getText().toString().trim()
				.equals(getString(R.string.cost_detail))) {
			dragLayout.minimize();
		}
		//分摊明细
		else if(tv_title.getText().toString().trim()
				.equals(getString(R.string.aa_detail))){
			AAdragLayout.minimize();
		} else {
			if (contentView.getChildCount() == 0) {
				finish();
			} else {
				contentView.onNextView();
				dataList.remove(list.size() - 1);
				payList.remove(list.size() - 1);
				statusList.remove(list.size() - 1);
				successList.remove(list.size() - 1);
			}
		}

    }
	@Override
	public void onClick(final View v) {
		switch (v.getId()) {
		case R.id.tv_right:
			if (contentView.getChildCount() == 0) {
				Tel.onTel(context, Value.TEL_KF);
//				Tel.onTel_KF(context, mOfficialOrderList);
			} else {
				Tel.onTel(context, Value.TEL_KF);
//				Tel.onTel_KF(context,
//						contentView.getChild(contentView.getChildCount() - 1)
//								.getMyOrderList());
			}
			break;
		case R.id.iv_left:
			onBack();
			break;
		case R.id.et_message:

			break;
		case R.id.tv_cost_detail:
			new AsyncTask<Void, Void, Void>(){
				OfficialPriceDetail price_detail=null;
				@Override
				protected Void doInBackground(Void... params) {
			
					price_detail = (OfficialPriceDetail) new JsonBuild().getData(OfficialPriceDetail.class,
							mOfficialOrderList.getPrice_Detail());
					// 更详细的费用明细。
					list_paydetail_more.clear();
					if(price_detail!=null&&price_detail.getOff_base_price()!=0){
					// 公务车基本费
					addPayDetail_More(getString(R.string.off_base_price),
							((price_detail == null) ? "0"
									: FormatUtil.onFormatPrice(price_detail.getOff_base_price())),
							PayDetailsAdapter.TYPE_PRICE);
					}else{
//					// 添加车费
//					addPayDetail_More(getString(R.string.fare), fare+"",
//							PayDetailsAdapter.TYPE_PRICE);
					}
					// 公务车时长费
					addPayDetail_More(getString(R.string.off_time_price),
							((price_detail == null) ? "0"
									: FormatUtil.onFormatPrice(price_detail.getOff_time_price())),
							PayDetailsAdapter.TYPE_PRICE);
					// 公务车里程费
					addPayDetail_More(getString(R.string.off_distance_price),
							((price_detail == null) ? "0"
									: FormatUtil.onFormatPrice(price_detail.getOff_distance_price())),
							PayDetailsAdapter.TYPE_PRICE);
					// 添加高速费
					addPayDetail_More(getString(R.string.highwey_fee),
							((price_detail == null) ? "0"
									: FormatUtil.onFormatPrice(price_detail.getHighwey_fee())),
							PayDetailsAdapter.TYPE_PRICE);
					// 行李费
					addPayDetail_More(getString(R.string.package_fee),
							((price_detail == null) ? "0"
									:FormatUtil.onFormatPrice(price_detail.getPackage_fee())),
							PayDetailsAdapter.TYPE_PRICE);
					// 超距离
					addPayDetail_More(
							getString(R.string.over_distance),
							((price_detail == null) ? "0"
									: FormatUtil.onFormatPrice(price_detail.getOver_distance())),
							PayDetailsAdapter.TYPE_PRICE);
					// 带小孩
					addPayDetail_More(getString(R.string.child_fee),
							((price_detail == null) ? "0"
									: FormatUtil.onFormatPrice(price_detail.getChild_fee())),
							PayDetailsAdapter.TYPE_PRICE);
					// 添加优惠劵
					addPayDetail_More(getString(R.string.end_coupon), coupon+"",
							PayDetailsAdapter.TYPE_REDUCE);
					// 添加第三方折扣
					addPayDetail_More(list.get(pay_id).get(PayAdapter.TEXT)
							+ getString(R.string.reduce), discount+"",
							PayDetailsAdapter.TYPE_REDUCE);
					return null;
				}

				@Override
				protected void onPostExecute(Void result) {
			
					dragLayout.setTime(DateFormat.onDateRemove_ss(mOfficialOrderList
							.getAppoint_time()));
					switch (order_type) {
					case Value.ORDER_TYPE_SN:
						dragLayout.setOrderType(getString(R.string.sn));
						dragLayout.setCountVisibility(View.GONE);
						break;
					case Value.ORDER_TYPE_PC:
						dragLayout.setOrderType(getString(R.string.pc));
//						dragLayout.setCount(String.format(getString(R.string.num),
//								mOfficialOrderList.getOrderDetail().getCount()));
						break;
					case Value.ORDER_TYPE_BC:
						dragLayout.setOrderType(getString(R.string.bc));
//						dragLayout.setCount(String.format(getString(R.string.num_car),
//								mOfficialOrderList.getOrderDetail().getCount()));
						break;
					case Value.ORDER_TYPE_KJ:
						dragLayout.setOrderType(getString(R.string.kj));
//						dragLayout.setCount(String.format(getString(R.string.num_jian),
//								mOfficialOrderList.getOrderDetail().getCount()));
						break;
					}
					dragLayout.setStart(mOfficialOrderList.getOrderDetail().getStart()
							.getAddress());
					dragLayout
							.setEnd(mOfficialOrderList.getOrderDetail().getEnd().getAddress());
					dragLayout.setPay(pay, status != STATUS_PAY, pay_gate);
					dragLayout.setRound_trip(tv_wf.getText().toString());
					dragLayout.setOwn(mOfficialOrderList.getOwn_expense());
					
					dragLayout.setPayDetailList(list_paydetail_more);
					mHandler.postDelayed(new Runnable() {
						
						@Override
						public void run() {
							dragLayout.maximize();
						}
					}, 200);
				
					super.onPostExecute(result);
				}
				
			}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
		
			
			
			

			break;
		case R.id.tv_apportion_detail:
			
			PayDetail mPayDetail=mOfficialOrderList.getPayDetail();
			if(mPayDetail!=null){
				AAdragLayout.maximize();
				AAdragLayout.setPayDetail(mPayDetail,FormatUtil.onFormatDecimal(pay),pay_gate);
			}else{
				ToastUtil.showToast(context, R.string.no_network);
			}
			
			
			break;
		case R.id.btn_coupon:
			mSharePopView.setOnShareDetaiFinish(OrderEvaluationActivity2.this);
			mSharePopView.getShareDetai();
			break;
		case R.id.ib_sjtel:
			// 用intent启动拨打电话
			context.startActivity(new Intent(Intent.ACTION_DIAL, Uri
					.parse("tel:" + mOfficialOrderList.getDriver_phone())));
			break;
		case R.id.btn_addOrganization:
			if(mOfficialOrderList.mOfficial_VclassInfo!=null){
			startActivityForResult(new Intent(context,AddOrganization.class)
			.putExtra(OrganizationMsg.extra_num, mOfficialOrderList.mOfficial_VclassInfo.getInfo().seat_num)
			.putExtra(OrganizationMsg.extra_type,OrganizationMsg.TYPE_ACTIVITY)
			.putExtra(OrganizationMsg.extra_root_org_id, mOfficialOrderList.root_org_id)
			.putExtra(OrganizationMsg.extra_depart_id, mOfficialOrderList.depart_id)
		    .putExtra(OrganizationMsg.extra_list,	(Serializable) list_organization)
			,resultCode);
		    }
			break;
		default:
			super.onClick(v);
			break;
		}

	}

	/**
	 * 显示状态，分别为，支付状态，评价状态，完成状态
	 */
	public void showStatus() {
		switch (getStatus()) {
		// 支付状态
		case STATUS_PAY:
			// 支付信息的显隐性
			layout_payway.setVisibility(View.VISIBLE);
//			layout_hint_paytype.setVisibility(View.GONE);

			setBtnCouponVisibility(false);
			listview_pay.setVisibility(View.VISIBLE);
			layout_cost.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.GONE);
			et_message.setVisibility(View.GONE);
			layout_message2.setVisibility(View.GONE);
//			layout_anonymous.setVisibility(View.GONE);
			rb_rating_b.setIsIndicator(false);
			rb_rating_b.setRating(0);
			layout_apportion.setVisibility(View.GONE);
			tv_apportion_detail.setVisibility(View.GONE);
			//分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.VISIBLE);
			tv_apportion_detail.setVisibility(View.GONE);
			btn_addOrganization.setVisibility(View.GONE);
			break;
		// 待评价状态
		case STATUS_EVA:
			// 支付信息的显隐性
			tv_need_pay.setText(pay_gate);
			layout_payway.setVisibility(View.GONE);
//			layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(pay_gate);

			setBtnCouponVisibility(true);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.VISIBLE);
			et_message.setVisibility(View.GONE);
//			layout_anonymous.setVisibility(View.VISIBLE);
			layout_apportion.setVisibility(View.GONE);
			//分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.VISIBLE);
			btn_addOrganization.setVisibility(View.GONE);
			//判断公务月结则显示
			if(isAA){
				tv_apportion_detail.setVisibility(View.VISIBLE);
			}else{
				tv_apportion_detail.setVisibility(View.GONE);
			}
			rb_rating_b.setRating(0);
			break;
		// 正在评价状态
		case STATUS_EVAING:
			// 支付信息的显隐性
			tv_need_pay.setText(pay_gate);
			layout_payway.setVisibility(View.GONE);
//			layout_hint_paytype.setVisibility(View.GONE);

			setBtnCouponVisibility(false);
			layout_evaluate.setVisibility(View.VISIBLE);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.GONE);
			et_message.setVisibility(View.VISIBLE);
//			layout_anonymous.setVisibility(View.VISIBLE);
			layout_apportion.setVisibility(View.GONE);
			//分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.GONE);
			
			
			rb_rating_b.setStepSize(1);
			new Handler().postAtTime(new Runnable() {
				@Override
				public void run() {
					rb_rating_b.setIsIndicator(false);
				}
			}, 200);
			break;
		// 完成状态
		case STATUS_FINISH:
			// 支付信息的显隐性
			tv_need_pay.setText(pay_gate);
			layout_payway.setVisibility(View.GONE);
//			layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(pay_gate);

			setBtnCouponVisibility(true);
			layout_evaluate.setVisibility(View.VISIBLE);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.VISIBLE);
			et_message.setVisibility(View.GONE);
//			layout_anonymous.setVisibility(View.VISIBLE);
			layout_message2.setVisibility(View.VISIBLE);
//			layout_anonymous.setVisibility(View.VISIBLE);
			et_message2.setText(et_message.getText().toString());
			rb_rating_b.setIsIndicator(true);
			isTouch = false;
			rb_rating_b.setStepSize(0.1F);
			rb_rating_b.setRating(FormatUtil.onFormatStar(mOfficialOrderList
					.getStar()));
			layout_apportion.setVisibility(View.GONE);
			//分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.VISIBLE);
			btn_addOrganization.setVisibility(View.GONE);
			//判断公务月结则显示
			if(isAA){
				tv_apportion_detail.setVisibility(View.VISIBLE);
			}else{
				tv_apportion_detail.setVisibility(View.GONE);
			}
			break;
		case STATUS_APPORTION:
			layout_payway.setVisibility(View.GONE);
			layout_apportion.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.GONE);
			listview_pay.setVisibility(View.GONE);
			//分摊详情跟费用详情的显示隐藏
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_detail.setVisibility(View.GONE);
			btn_addOrganization.setVisibility(View.VISIBLE);
			break;
		}
	}

	/**
	 * 设置状态
	 */
	public void setStatus(int status) {
		this.status = status;
		onSetTitle(status);
		switch (status) {
		// 支付状态
		case STATUS_PAY:
			// mOfficialOrderList.setValuate_status(Value.PAY_NO+"");
			btn_confirm.setText(getString(R.string.confirm_pay2));
			ib_sj.setVisibility(View.VISIBLE);
			break;
		// 待评价状态
		case STATUS_EVA:
			mOfficialOrderList.setValuate_status(Value.VALUATE_STATUS_NO + "");
			btn_confirm.setText(R.string.agin_xiadan);
			ib_sj.setVisibility(View.GONE);
			break;
		// 正在评价状态
		case STATUS_EVAING:
			mOfficialOrderList.setValuate_status(Value.VALUATE_STATUS_NO + "");
			btn_confirm.setText(R.string.submit_evaluation);
			ib_sj.setVisibility(View.GONE);
			break;
		// 完成状态
		case STATUS_FINISH:
			MyOrderEvaluateInfoTask.getInstance(context, order_id).setOnEvaluateInfoListener(this);
			mOfficialOrderList.setValuate_status(Value.VALUATE_STATUS + "");
			mOfficialOrderList.setSuggest(et_message.getText().toString());
			btn_confirm.setText(R.string.agin_xiadan);
			ib_sj.setVisibility(View.GONE);
			break;
		case STATUS_APPORTION:
			btn_confirm.setText(context.getString(R.string.text_finish));
			break;
		}
		showStatus();
		db_myorder.onUpdate(mOfficialOrderList);
	}

	/**
	 * 获取当前状态，
	 */
	public int getStatus() {
		return status;
	}

	private int id = -1;

	@Override
	protected void onDestroy() {
		jmsg_data = null;
		if (mOrderDetailTask != null
				&& mOrderDetailTask.getStatus() != AsyncTask.Status.FINISHED)
			mOrderDetailTask.cancel(true);
		super.onDestroy();
	}

	@Override
	public void finish() {
		ArrayList<String> lits_order_id2 = new ArrayList<String>();
		if (lits_order_id.size() > 0) {
			lits_order_id2.add(lits_order_id.get(0));
			if (id >= 0)
				for (int i = 0; i <= id; i++) {
					lits_order_id2.add(lits_order_id.get(i + 1));
				}
		}
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		bundle.putStringArrayList(OrderMsg.lits_order_id, lits_order_id2);
		intent.putExtras(bundle);
		setResult(resultCode, intent);
		super.finish();
	}

	@Override
	public void onNotify(int type, JSONObject jb, Msgs.Data msgs_data) {
		if (!isonNotify)
			return;
		/** 是否继续执行父类 */
		boolean isContinue = true;
		String order_id = null;
		switch (type) {
		case GMsg.OFFICAIL_ONLINE_OFFCAR:
			isContinue = false;

			try {
				JSONObject json_jmsg = jb.getJSONObject(GMsg.msg_jmsg);
				JSONObject json_data = new JSONObject(
						json_jmsg.getString(GMsg.msg_data));
				order_id = json_data.getString(GMsg.msg_order_id);
			} catch (JSONException e1) {
			}
			if (order_id != null) {
				addCardView(order_id);
			}
			break;
		case GMsg.ONLINE_FINISH:
		case GMsg.OFFICAIL_ONLINE_FINISH:
			jmsg_data = "";
			if (msgs_data != null) {
				int card = -1;
				order_id = msgs_data.getOrder_id();
				if (contentView.getChildCount() > 0) {
					for (int i = 0; i < contentView.getChildCount(); i++) {
						String order_id_list = contentView.getChild(i)
								.getOrderId();
						if (order_id.equals(order_id_list)) {
							card = i;
							break;
						}
					}
					if (card != -1) {
						contentView.setPaySuccuss(card);
					} else {
						if (order_id.equals(this.order_id)) {
							onPaySuccuss();
						}
					}
				} else {
					if (order_id.equals(this.order_id)) {
						onPaySuccuss();
					}
				}
			}

			break;
		case GMsg.ONLINE_KF_CHANGE:
			ToastUtil.showToast(context, R.string.toast_change);
			jmsg_data = "";
			if (msgs_data != null) {
				int card = -1;
				order_id = msgs_data.getOrder_id();
				if (contentView.getChildCount() > 0) {
					for (int i = 0; i < contentView.getChildCount(); i++) {
						String order_id_list = contentView.getChild(i)
								.getOrderId();
						if (order_id.equals(order_id_list)) {
							card = i;
							break;
						}
					}
					if (card != -1) {
						contentView.setOrderDetail(card, order_id);
					} else {
						if (order_id.equals(this.order_id)) {
							getOrderDetail(order_id, true);
						}
					}
				} else {
					if (order_id.equals(this.order_id)) {
						getOrderDetail(order_id, true);
					}
				}
			}
			break;
		}
		if (isContinue) {
			super.onNotify(type, jb, msgs_data);
		}
	}

	@Override
	public void onDragViewStatus(boolean isOpen) {
		if (isOpen) {
			setOnCloseSwipeLayout(true);
			setTitle(getString(R.string.cost_detail));
		} else {
			if (contentView.getChildCount() == 0) {
				setOnCloseSwipeLayout(false);
				onSetTitle(status);
			} else {
				int mstatus = contentView.getChild(
						contentView.getChildCount() - 1).getStatus();
				onSetTitle(mstatus);
			}

		}

	}
	@Override
	public void onAADragViewStatus(boolean isOpen) {
		if (isOpen) {
			setOnCloseSwipeLayout(true);
			setTitle(getString(R.string.aa_detail));
		} else {
			if (contentView.getChildCount() == 0) {
				setOnCloseSwipeLayout(false);
				onSetTitle(status);
			} else {
				int mstatus = contentView.getChild(
						contentView.getChildCount() - 1).getStatus();
				onSetTitle(mstatus);
			}

		}

	}

	/**
	 * 添加费用明细列表
	 */
	public void addPayDetail(String name, String money, String type) {
		Map<String, String> map = new HashMap<String, String>();
		map.put(PayDetailsAdapter.PAYDETAIL_NAME, name);
		map.put(PayDetailsAdapter.PAYDETAIL_MONEY, money);
		map.put(PayDetailsAdapter.PAYDETAIL_TYPE, type);
		list_paydetail.add(map);
	}

	/**
	 * 添加更加费用明细列表，及跳转到别的页面
	 */
	public void addPayDetail_More(String name, String money, String type) {
		Map<String, String> map = new HashMap<String, String>();
		map.put(PayDetailsAdapter.PAYDETAIL_NAME, name);
		map.put(PayDetailsAdapter.PAYDETAIL_MONEY, money);
		map.put(PayDetailsAdapter.PAYDETAIL_TYPE, type);
		list_paydetail_more.add(map);
	}

	/**
	 * 设置我要优惠劵按钮的显示或隐藏
	 */
	public void setBtnCouponVisibility(boolean IsVisibility) {
		if (IsVisibility) {
//			btn_coupon.setVisibility(View.VISIBLE);
		} else {
//			btn_coupon.setVisibility(View.GONE);
		}
	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {

		/** 使用SSO授权必须添加如下代码 */
		UMSsoHandler ssoHandler = mSharePopView.getController().getConfig()
				.getSsoHandler(requestCode);
		if (ssoHandler != null) {
			ssoHandler.authorizeCallBack(requestCode, resultCode, data);
		}
		if(this.requestCode==requestCode&&this.resultCode==resultCode){
			 String type=data.getStringExtra(OrganizationMsg.extra_type);
			 list_organization =(List<Map<String, String>>) data.getSerializableExtra(OrganizationMsg.extra_list);
			 List<OrginFos> list_orginfos=new ArrayList<OrginFos>();
			 int num=0;
				for(int i=0;i<list_organization.size();i++){
					OrginFos orginfos=new OrginFos();
					orginfos.org_id=list_organization.get(i).get(OrganizationAdapter.ORG_ID);
					orginfos.org_name=list_organization.get(i).get(OrganizationAdapter.ORG_NAME);
					orginfos.count=Integer.parseInt(list_organization.get(i).get(OrganizationAdapter.ORG_NUM));
					num=num+orginfos.count;
					list_orginfos.add(orginfos);					
				}
			 if(type.equals(OrganizationMsg.TYPE_ACTIVITY)){
				this.list_orginfos.clear();
				if(list_orginfos!=null&&!list_orginfos.isEmpty()){
					this.list_orginfos.addAll(list_orginfos);
					 tv_cost_apportion_content.setText(String.format(getString(R.string.text_apportion_detail), list_orginfos.size(),num,FormatUtil.onFormatDecimal2(pay/num)));
					 tv_cost_apportion_content.setVisibility(View.VISIBLE);
				}else{
					tv_cost_apportion_content.setVisibility(View.GONE);
				}
				
			 }
			 else if(type.equals(OrganizationMsg.TYPE_CARD)){
				 contentView.setApportionContent(contentView.getChildCount()-1,
						 String.format(getString(R.string.text_apportion_detail), list_orginfos.size(),num,FormatUtil.onFormatDecimal2(pay/num))
						 ,list_orginfos,list_organization);
				
			 }
		}
		super.onActivityResult(requestCode, resultCode, data);
	}

	@Override
	public void onShareDetaiFinish(String sum) {
		if (sum.equals("0")) {
			ToastUtil.showToast(context, R.string.no_network);
		} else {
			mSharePopView.onShow(btn_coupon);
		}
	}

	/**
	 * 支付完成后通知赋值,用完及时清空,重新打开页面则赋值""
	 */
	public static String jmsg_data = "";

	@Override
	public void onWeiXinPayFinish(boolean isSuccess) {
		hideInput();
		if (isSuccess) {
			getOrderDetail(order_id, false);
			Msgs.Data msgs_data = null;
			if (jmsg_data != null && !jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class, jmsg_data.toString());
			}
			if (msgs_data != null) {
				onNotify(GMsg.ONLINE_FINISH, null, msgs_data);
			} else {
				if(getStatus()==STATUS_PAY){
			    	btn_confirm.setText(R.string.btn_confirmation);
				}
			}
		} else {

		}

	}

	@Override
	public void onAliPayFinish(boolean isSuccess) {
		hideInput();
		if (isSuccess) {
			getOrderDetail(order_id, false);
			Msgs.Data msgs_data = null;
			if (jmsg_data != null && !jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class, jmsg_data.toString());
			}
			if (msgs_data != null) {
				onNotify(GMsg.ONLINE_FINISH, null, msgs_data);
			} else {
				if(getStatus()==STATUS_PAY){
			    	btn_confirm.setText(R.string.btn_confirmation);
				}
			}
		} else {

		}
	}

	/**
	 * 支付成功
	 */
	public void onPaySuccuss() {
		if (status != STATUS_EVA) {
			new Handler().postDelayed(new Runnable() {

				@Override
				public void run() {
					setStatus(STATUS_EVA);
					mOfficialOrderList.setOrder_status((Value.ORDER_STATUS_FINISH)+"");
					db_myorder.onUpdate(mOfficialOrderList);
					db_myordering.onDelete(context, order_id);
					onUpdateView();
					getOrderDetail(order_id, true);
				}
			}, 300);
			onShowCoupon();
		}
	}
	public void onUpdateView(){
		FirstLoad=true;
	}

	public void onShowCoupon() {
//		new Handler().postDelayed(new Runnable() {
//
//			@Override
//			public void run() {
//				if (coupondialog != null && !coupondialog.isShowing()) {
//					coupondialog.show();
//				}
//				coupondialog.setOnClickLeftListener(new onClickLeftListener() {
//					@Override
//					public void onClickLeft() {
//						coupondialog.dismiss();
//					}
//				});
//				coupondialog
//						.setOnClickRightListener(new onClickRightListener() {
//
//							@Override
//							public void onClickRight() {
//								coupondialog.dismiss();
//								mSharePopView
//										.setOnShareDetaiFinish(OrderEvaluationActivity2.this);
//								mSharePopView.getShareDetai();
//							}
//						});
//			}
//		}, 1000);

	}

	@Override
	public void onOrderEvaluate(int status) {
		if(status==MyOrderEvaluateTask.STATUS_SUCCESS){
		ToastUtil.showToast(context, R.string.submit_success);
		et_message2.setText(et_message.getText().toString());
		mOfficialOrderList.setStar(rb_rating_b.getRating() * 20);
		setStatus(STATUS_FINISH);
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				getOrderDetail(order_id, true);
			}
		}, 1000);
		}
	}

	@Override
	public void onVclassInfo(Official_VclassInfo mOfficial_VclassInfo,String class_id) {
		if(mOfficialOrderList.getVehicle_id().equals(class_id)){
		mOfficialOrderList.mOfficial_VclassInfo=mOfficial_VclassInfo;
		}
	}

	@Override
	public void onEvaluateInfo(int status, Info info) {
		if(status==MyOrderEvaluateInfoTask.STATUS_SUCCESS){
			if(info!=null){
				et_message2.setText(info.getContent());
				rb_rating_b.setRating(FormatUtil.onFormatStar((info.getStar())));
			}
		}else{
			 
		}
	}

	@Override
	public void onStarFinish(String order_id, int star) {
		mOfficialOrderList.setDriver_star( star);
		tv_rating.setText(FormatUtil.onFormatStar((float)star) + "");
		rb_rating.setRating(FormatUtil.onFormatStar((float) star));
	}

	@Override
	public void onAAFinish(int status) {
		if(status==MyAATask.STATUS_SUCCESS){
			isAA=true;
			pay_gate=getString(R.string.pay_way_gongwu);
			setStatus(STATUS_EVA);
			new Handler().postAtTime(new Runnable() {
				
				@Override
				public void run() {
					getOrderDetail(order_id, false);
				}
			}, 500);
	
		}
	}

	@Override
	public void onMonthlyFinish(int status) {
		if(status==MyAATask.STATUS_SUCCESS){
			isAA=false;
			pay_gate=getString(R.string.pay_way_gongwu);
			setStatus(STATUS_EVA);
			new Handler().postAtTime(new Runnable() {
				
				@Override
				public void run() {
					getOrderDetail(order_id, false);
				}
			}, 500);
	
		}
	}
}
